package com.project.harmonyledger.controller.account;

import com.project.harmonyledger.common.response.Result;
import com.project.harmonyledger.dto.LoginParams;
import com.project.harmonyledger.service.user.account.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/api/user")
public class LoginController {
  @Autowired
  private LoginService loginService;

  @PostMapping("/login")
  public Result<Map<String, String>> login(@RequestBody LoginParams loginParams) {
    return loginService.getToken(loginParams.getUsername(), loginParams.getPassword());
  }
}
